<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/1/3
 * Time: 上午10:48
 */

namespace app\common\controller;

use thans\auth\facade\Token;
use think\facade\Request;

class Admin extends Base
{
    public $isAjax;

    public function initialize()
    {
        $res = $this->isLogin();
        if (!$res) {
            if ($this->isAjax) {
                $this->result('', 4001, '请先登录', 'json');
            }
            $this->error('请重新登录', url('/admin/login?redirect=' . urlencode(Request::url(true)), '', ''));
        }
        $res = $this->adminAuth();
        if (!$res) {
            if ($this->isAjax) {
                $this->result('', 4001, '暂无权限', 'json');
            }
            $this->error('暂无权限', '/', '', '-1');
        }
    }
}
